# @FileName  :  teacher.py
# @Time      :  2025/7/29 14:13
# @Author    :  Ayanami
# @info      :  教师相关的Pydantic模型

# @FileName  :  teacher.py
# @Time      :  2025/7/28 22:40
# @Author    :  Ayanami
# @info      :  教师相关的Pydantic模型

from datetime import date, datetime
from typing import Optional
from pydantic import BaseModel, Field
from app.models.models import DictionaryType
from app.schemas.student import DictionaryResponse, DictionarySimple


class TeacherBase(BaseModel):
    """教师基础模型"""
    name: str = Field(..., max_length=50, description="讲师姓名")
    phone: str = Field(..., max_length=20, description="联系方式")
    id_card: str = Field(..., max_length=18, description="身份证号")
    specialty: str = Field(..., max_length=100, description="教学方向")
    hire_date: date = Field(..., description="入职时间")
    education: str = Field(..., description="教育经历")
    level: str = Field(..., max_length=50, description="职称级别")
    category_id: int = Field(..., description="分类ID")
    notes: Optional[str] = Field(None, description="备注")


class TeacherCreate(TeacherBase):
    """创建教师模型"""
    teacher_id: str = Field(..., max_length=20, description="教工号")


class TeacherUpdate(BaseModel):
    """更新教师模型"""
    name: Optional[str] = Field(None, max_length=50, description="讲师姓名")
    phone: Optional[str] = Field(None, max_length=20, description="联系方式")
    id_card: Optional[str] = Field(None, max_length=18, description="身份证号")
    specialty: Optional[str] = Field(None, max_length=100, description="教学方向")
    hire_date: Optional[date] = Field(None, description="入职时间")
    education: Optional[str] = Field(None, description="教育经历")
    level: Optional[str] = Field(None, max_length=50, description="职称级别")
    category_id: Optional[int] = Field(None, description="分类ID")
    notes: Optional[str] = Field(None, description="备注")



class TeacherResponse(TeacherBase):
    """教师响应模型"""
    id: int
    teacher_id: Optional[str] = Field(None, max_length=20, description="教工号")
    sessions_count: int = Field(default=0, description="授课场次")
    category: DictionarySimple = Field(..., description="分类")
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True


class TeacherListResponse(BaseModel):
    """教师列表响应模型"""
    total: int
    items: list[TeacherResponse]


class TeacherQuery(BaseModel):
    """教师查询参数"""
    name: Optional[str] = Field(None, description="姓名模糊查询")
    teacher_id: Optional[str] = Field(None, description="教工号查询")
    specialty: Optional[str] = Field(None, description="教学方向模糊查询")
    category_id: Optional[int] = Field(None, description="分类查询")
    level: Optional[str] = Field(None, description="职称级别查询")
    skip: int = Field(0, ge=0, description="跳过记录数")
    limit: int = Field(10, ge=1, le=100, description="返回记录数")
